/*
 * Configuration.h
 *
 *  Created on: Sep 23, 2011
 *      Author: erudhes
 */
#ifndef CONFIGURATION_H_
#define CONFIGURATION_H_
#include <map>
#include <wx/wx.h>
#include <wx/xml/xml.h>

namespace Configuration
{
	class Vehicle
	{
		public:
		Vehicle(wxXmlNode* Node);
		const wxString& getName() const;
		void setName(const wxString& name);
		const wxPoint& getPosition() const;
		void setPosition(const wxPoint& position);

		private:
			wxString mName;
			wxPoint mPosition;
			wxXmlNode* mNode;
	};

	class Level
	{
		public:
			Level(wxXmlNode* Node);
			const wxString& getName() const;
			void setName(const wxString& name);
			Vehicle* getVehicleA();
			Vehicle* getVehicleB();

		private:
			wxString mName;
			Vehicle* mVehicleA;
			Vehicle* mVehicleB;
			wxXmlNode* mNode;
	};

	class Levels
	{
		public:
			Levels(wxXmlNode* node);
			const wxString& getPath() const;
			void setPath(const wxString& path);
			Level* getLevel(const wxString& name);
			void setLevel(Level* level);

		private:
			wxString mPath;
			std::map<wxString, Level*> mLevels;
			wxXmlNode* mNode;
	};

	class NetworkConfiguration
	{
		public:
			NetworkConfiguration(wxXmlNode* node);
			int getPortNumber() const;
			void setPortNumber(int portNumber);

		private:
			int mPortNumber;
			wxXmlNode* mNode;
	};

	class Configuration
	{
		public:
			Configuration(const wxString& configFile);
			const wxString& getLogoPath() const;
			void setLogoPath(const wxString& logoPath);
			int getDotSize() const;
			void setDotSize(int dotSize);
			NetworkConfiguration* getNetworkConfiguration();
			Levels* getLevels();
			const wxString& getPathSeparator() const;

		private:
			wxString mLogoPath;
			int mDotSize;
			NetworkConfiguration* mNetworkConfiguration;
			Levels* mLevels;
			wxXmlDocument mXmlConfig;
	};

/**
 * Vehicle class
 */

	inline const wxString& Vehicle::getName() const
	{
		return mName;
	}

	inline void Vehicle::setName(const wxString& name)
	{
		mName = name;
	}

	inline const wxPoint& Vehicle::getPosition() const
	{
		return mPosition;
	}

	inline void Vehicle::setPosition(const wxPoint& position)
	{
		mPosition = position;
	}

/**
 * Level class
 */

	inline const wxString& Level::getName() const
	{
		return mName;
	}

	inline void Level::setName(const wxString& name)
	{
		mName = name;
	}

	inline Vehicle* Level::getVehicleA()
	{
		return mVehicleA;
	}

	inline Vehicle* Level::getVehicleB()
	{
		return mVehicleB;
	}

/**
 * Levels class
 */

	inline const wxString& Levels::getPath() const
	{
		return mPath;
	}

	inline void Levels::setPath(const wxString& path)
	{
		mPath = path;
	}

	inline Level* Levels::getLevel(const wxString& name)
	{
		return mLevels[name];
	}

	inline void Levels::setLevel(Level* level)
	{
		mLevels[level->getName()] = level;
	}

/**
 * NetworkConfiguration class
 */

	inline int NetworkConfiguration::getPortNumber() const
	{
		return mPortNumber;
	}

	inline void NetworkConfiguration::setPortNumber(int portNumber)
	{

	}

/**
 * Configuration class
 */

	inline const wxString& Configuration::getLogoPath() const
	{
		return mLogoPath;
	}

	inline void Configuration::setLogoPath(const wxString& logoPath)
	{
		mLogoPath = logoPath;
	}

	inline int Configuration::getDotSize() const
	{
		return mDotSize;
	}

	inline void Configuration::setDotSize(int dotSize)
	{
		mDotSize = dotSize;
	}

	inline NetworkConfiguration* Configuration::getNetworkConfiguration()
	{
		return mNetworkConfiguration;
	}

	inline Levels* Configuration::getLevels()
	{
		return mLevels;
	}

	inline const wxString& Configuration::getPathSeparator() const
	{
#ifdef __WXMSW__
		static const wxString pathSeparator(wxT("\\"));
#else
		static const wxString pathSeparator(wxT("/"));
#endif
		return pathSeparator;
	}
}

#endif /* CONFIGURATION_H_ */
